﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NServiceBus.Management.Messages.EndpointControl;

namespace NServiceBus.Management.MessageHandlers
{
    public class EndpointMessageHandler : IMessageHandler<StopCommand>,
                                          IMessageHandler<StartCommand>,
                                          IMessageHandler<PingCommand>
    {
        public IEndpointManager EndpointManager { get; set; }
        public IBus Bus { get; set; }

        #region MessageHandler Members
        public void Handle(StopCommand message)
        {
            EndpointManager.Stop();
        }

        public void Handle(StartCommand message)
        {
            EndpointManager.Start();
        }

        public void Handle(PingCommand message)
        {
            Bus.Reply(new PingResponse());
        }

        #endregion
    }
}
